#include<bits/stdc++.h>
using namespace std;
#define int long long

int a[10005], preSum[10005];

signed main() {
	int n;
	cin >> n;
	for (int i = 1; i <= n ; i++) {
		cin >> a[i];
	}

	for (int i = 1; i <= n; i++) {
		preSum[i] = a[i];	// 保证由 a[i] 结尾
		vector<int> dp;
		for (int j = 1; j < i; j++) {
			if (a[j] >= a[i])	continue;
			auto t = lower_bound(dp.begin(), dp.end(), a[j]);
			if (t == dp.end())
				dp.push_back(a[j]);
			else
				dp[t - dp.begin()] = a[j];
		}
		for (int j : dp)
			preSum[i] += j;
		cout << preSum[i] << " ";
	}
	return 0;
}
